package cn.zhengzhou.springbootmybatis.pojo;

import lombok.Data;

import java.io.Serializable;

@Data
public class ResultVo<T> implements Serializable {

    private int code;
    private String msg;
    private T data;
    public static <T> ResultVo<T>  success(T data) {

        return success(200,"操作成功",data);
    }

    public static <T> ResultVo<T> success(int code, String msg, T data) {
        ResultVo<T> r = new ResultVo<T>();
        r.setCode(code);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }
    public static <T> ResultVo<T> fail(int code, String msg, T data) {
        ResultVo<T> r = new ResultVo<T>();
        r.setCode(code);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }
    public static <T> ResultVo<T> fail(T data) {
        return fail(500,"执行失败",data);
    }
}
